<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>TechNova - Customer Reviews</title>
    <link rel="stylesheet" href="../css/styles.css">
</head>
<body>
    <div class="container">
        <!-- header.php -->
        <?php include '../common/header.php'; ?>
		
		<div class="contact-form">
			<h2>Contact Form</h2>
			<?php
			session_start();
			include '../dbconnect.php';
			// 检查用户是否已经登录
			if (!isset($_SESSION['uid']) || !isset($_SESSION['uname'])) {
				echo "请先登录！";
				exit;
			}
			$uid = $_SESSION['uid'];
			$uname = $_SESSION['uname'];
			// 从数据库中获取用户信息
			$sql = "SELECT * FROM user WHERE U_ID = ?";
			$stmt = $conn->prepare($sql);
			$stmt->bind_param("s", $uid);
			$stmt->execute();
			$result = $stmt->get_result();
			if ($result->num_rows > 0) {
				$row = $result->fetch_assoc();
				$name = $row['U_Username'];
				$email = $row['U_Email'];
			} else {
				$name = '';
				$email = '';
			}
			$stmt->close();
			$conn->close();
			?>
			<form action="submit_review.php" method="post">
				username:<input type="text" name="name" value="<?php echo htmlspecialchars($name); ?>" placeholder="Your Name" required>
				email:<input type="email" name="email" value="<?php echo htmlspecialchars($email); ?>" placeholder="Your Email" required>
				message:<textarea name="message" placeholder="Your Message" required></textarea>
				<button type="submit" class="button">Send Message</button>
			</form>
		</div>
		
        
		<div class="testimonials">
			<h1>Customer Reviews</h1>
			<?php
			// 数据库连接信息
			include '../dbconnect.php';
			$sql = "SELECT * FROM reviews where IS_DELETE = 0";
			$result = $conn->query($sql);
			if ($result->num_rows > 0) {
				while ($row = $result->fetch_assoc()) {
					?>
					<div class="testimonial">
					<!-- 如果没有图片，可以隐藏 <img src="<?php echo $row['REVIEWS_PICTURE']; ?>" alt="Customer Image" style="display:none;">  -->
						<img src="<?php echo $row['REVIEWS_PICTURE']; ?>" alt="Customer Image"> 
						
						<h2>user name:<?php echo htmlspecialchars($row['REVIEWS_NAME']); ?></h2>
						<p>user content :<?php echo htmlspecialchars($row['REVIEWS_DESC']); ?></p>
						<small>user email:<?php echo htmlspecialchars($row['REVIEWS_EMAIL']); ?></small>
						<br>
						<small>reviews time:<?php echo $row['REVIEWS_TIME']; ?></small>
					</div>
					<?php
				}
			} else {
				echo "<p>No reviews available.</p>";
			}
			?>
		</div>
		
		<!--
			<div class="testimonials">
			    <h1>Customer Reviews</h1>
			    
			    <div class="testimonial">
			        <img src="../images/luke.jpg" alt="Customer 1">
			        <h2>Luke - CEO of a Technology Startup</h2>
			        <p>"TechNova's AI solution has helped us increase operational efficiency by 30%. Their team is professional and efficient, and they are reliable partners."</p>
			    </div>
			    
			    <div class="testimonial">
			        <img src="../images/james.jpg" alt="Customer 2">
			        <h2>James - CTO of a Financial Institution</h2>
			        <p>"We adopted TechNova's blockchain technology, which significantly enhanced the security and transparency of transactions. Their technical support team is responsive and the service is first-class."</p>
			    </div>
			    
			    <div class="testimonial">
			        <img src="../images/will.jpg" alt="Customer 3">
			        <h2>Will - Director of a Manufacturing Company</h2>
			        <p>"TechNova's customized Internet of Things solution for us has greatly increased the intelligence level of our production line. Their innovation ability is impressive."</p>
			    </div>
			</div>
		 -->
        
		
    </div>
    
    <!-- footer.php -->
    <?php include '../common/footer.php'; ?>
</body>
</html>